#ifndef __ITIMER_H__
#define __ITIMER_H__

class ITimer
{
protected:
	u32 TimeStart;
	u32 Time;
	u32 Actual;
	bool Working;
	bool Ended;

public:
	ITimer() : Working(false),TimeStart(0),Time(0),Ended(false)
	{
	}

	virtual ~ITimer()
	{
	}

	inline void SetTime(u32 TimeValue)	{	Time = TimeValue;	}
	inline void Start(u32 ActualTime)
	{
		TimeStart = ActualTime;
		Working = true;
		Ended = false;
		Actual = Time;
	}

	inline void Update(u32 ActualTime)
	{
		if (Working)
		{
			Actual = ActualTime - TimeStart;
			if (Actual > Time)
			{
				Ended = true;
				Working = false;
				Actual = Time;
			}
		}
	}

	inline u32 GetActual()
	{
		return Actual;
	}

	inline u32 GetPassed()
	{
		return Time - Actual;
	}

	inline bool IsEnded()
	{
		return Ended;
	}
};

#endif
